<?php
namespace yitongpay\lib;



use think\facade\Config;
use think\facade\Log;

class ToolServer
{
    protected $values = [];

    // 格式化参数格式化成url参数
    public function ToUrlParams($ext = '&')
    {
        $buff = "";
        foreach ($this->values as $k => $v) {
            $buff .= $k . "=" . $v . $ext;
        }
        $buff = trim($buff, $ext);
        return $buff;
    }

    public function getSign($p = true, $ext = '&')
    {
        if($p) {
            ksort($this->values);
        }
        $string = $this->ToUrlParams($ext);
        $this->getSignValue($string.$ext);
    }

    public function getSignValue($string)
    {
        $this->values['signValue'] = md5($string.Config::get('yitong.datakey'));
    }

    public function GetValues()
    {
        return $this->values;
    }

    public function SetValues($array = [])
    {
        return $this->values = array_merge($this->values, $array);
    }
}